﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Shop_GoodPV_Search : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            BindData();            
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestLoginPage = "Shop/GoodPV_Search.aspx";

        base.OnInit(e);
    }

    #endregion

    private void BindData()
    {
        string Condition = "ShopID = 1 ";

        if (txtCondition.Text != "")
        {
            Condition += " and " + ddlType.SelectedValue + " like '%" + txtCondition.Text.Trim() + "%'"; 
        }

        DataTable dt = new DAL.Views.V_Shop_Good().Open("", Condition, "");

        if (dt == null)
        {
            Shove._Web.JavaScript.Alert(this, "数据库连接失败");

            return;
        }

        g.DataSource = dt;
        g.DataBind();        
        gPager.Visible = (dt.Rows.Count > 0);
    }

    protected void g_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
        {
           
        }
    }

    protected void gPager_PageWillChange(object Sender, Shove.Web.UI.PageChangeEventArgs e)
    {
        BindData();
    }

    protected void gPager_SortBefore(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
    {
        BindData();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BindData();
    }

}